package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.service.MatchHostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 匹配主播
 * @author jh
 * 2018/9/30
 */
@RestController
@RequestMapping(value = "/match/host")
@Api(value = "匹配主播", tags = "匹配主播")
public class MatchHostController {

    @Resource
    private MatchHostService matchHostService;

    /**
     * 1.5.5 随机返回一个白包主播
     * @return
     */
    @GetMapping()
    public JSONObject getRandomHostUser(){
        return matchHostService.getRandomHostUser();
    }

    @GetMapping(value = "/icon")
    @ApiOperation(value = "获取随机主播头像", notes = "返回值为图片地址的list"
            , produces = MediaType.APPLICATION_JSON_VALUE)
    public List<String> getRandomHostIcons() {
        return matchHostService.getRandomHostIcons();
    }

    @PostMapping(value = "")
    @ApiOperation(value = "匹配主播,并打招呼")
    public void sendMatchMsg(Authentication auth) {
//        Subject subject = (Subject) auth.getPrincipal();
//        Long userId = subject.getId();
//        matchHostService.send(userId);
    }
}
